package com.yangfei.mystudy1020.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.yangfei.mystudy1020.R;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class EventBusActivity extends Activity {

    @BindView(R.id.btn_send)
    Button mBtnSend;

    public static class MessageEvent {
        String msg;

        public MessageEvent(String msg) {
            this.msg = msg;
        }
    }

    int mCount = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_event_bus);
        ButterKnife.bind(this);
    }

    @OnClick(R.id.btn_send)
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.btn_send: {
                EventBus.getDefault().post(new MessageEvent("msg number " + mCount));
                mBtnSend.setText("msg number "+mCount);
                mCount++;
                break;
            }
        }
    }


}
